package com.lms.thread.demo1;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-01-17 10:05
 * @Description: ${Description}
 */
public class Test {
    public static void main(String[] args) throws InterruptedException {
        TaskThread taskThread = new TaskThread();
        taskThread.setName("taskThread-0");
//        taskThread.start();//只能调用一次，否则抛出java.lang.IllegalThreadStateException
//        TaskRunnable taskRunnable = new TaskRunnable();
//        new Thread(taskRunnable).start();
        Thread.currentThread().setPriority(7);
        Thread thread = new Thread(taskThread);
//        thread.setDaemon(true);//设置为守护线程
        System.out.println("线程启动前，线程是否处于活动状态：isAlive():"+thread.isAlive());
        thread.start();
        System.out.println("线程启动后，线程是否处于活动状态：isAlive():"+thread.isAlive());
        thread.interrupt();
        System.out.println("thread优先级："+thread.getPriority());//默认为5，默认父线程组一样的优先级
        System.out.println("main优先级："+Thread.currentThread().getPriority());
//        taskThread.start();
        Thread.sleep(2000);
    }
}
